﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Xml.Linq;
using Microsoft.Phone.Shell;

using System.Windows.Navigation;
using Microsoft.Advertising.Mobile.UI;
using MyToolkit.Multimedia;


namespace ActivityTracker.Views.Help
{
    public partial class Help : PhoneApplicationPage
    {
        List<MenuProperties> l = new List<MenuProperties>();
        int count = 0;
        string id = string.Empty;
        string url = string.Empty;
        XDocument xdoc = null;
        string xmlpath ="DefaultData/Help.xml";
        private SolidColorBrush adcontrolborder = new SolidColorBrush(Colors.Transparent);
        public Help()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(Help_Loaded);
        }
        void Help_Loaded(object sender, RoutedEventArgs e)
        {
         

            if (NavigationContext.QueryString.TryGetValue("id", out id))

                if (NavigationContext.QueryString.TryGetValue("url", out url))

                    if (url == "")
                    {
                        ApplicationBarIconButton b = (ApplicationBarIconButton)ApplicationBar.Buttons[0];
                        ApplicationBar.Buttons.Remove(b);
                    }
            xdoc = XDocument.Load(xmlpath);

            var findEle = from i in xdoc.Descendants("de") where i.Attribute("id").Value.ToString() == id select i;


            foreach (var n in findEle.Descendants("c"))
            {
                tblkVideosTitle.Text = n.Attribute("title").Value;
                break;
            }
            foreach (var d in findEle.Descendants("c").Elements("des"))
            {

                MenuProperties h = new MenuProperties();
                h.HelpText = d.Value;
                l.Add(h);
            }


            lbxhelp.ItemsSource = l;
        }
        private void ApplicationBarIconButton_youtube_Click(object sender, EventArgs e)
        {
            YouTube.LoadYoutubeVideo(url); 
        }
     
   
       
    }
}